<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1253">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.2  (Win32)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20110604;12120751">
	<STYLE TYPE="text/css">
	<!--
		@page { size: 21cm 29.7cm; margin-left: 2.01cm; margin-right: 0.99cm }
	-->
	</STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P><BR><BR>
</P>
<P><FONT SIZE=6 STYLE="font-size: 22pt"><U><B>Description of the Vec
class</B></U></FONT></P>
<P STYLE="font-weight: medium; text-decoration: none">The <B>Vec</B>
class implements one-dimensional dense vectors in ScalaSci. 
</P>
<P><BR><BR>
</P>
<P><FONT SIZE=4><U><B>Constructors</B></U></FONT></P>
<OL>
	<LI><P ALIGN=LEFT STYLE="text-decoration: none"><B>Vec(len:
	Integer): Creates a vector of size len initialized to zeros</B></P>
</OL>
<P STYLE="font-weight: medium; text-decoration: none"><A NAME="DDE_LINK"></A>
<I>var v = new Vec(100) </I>// creates a vector with 100 elements
initialized to zero values.</P>
<P><BR><BR>
</P>
<P STYLE="text-decoration: none"><B>2. Vec(da: Array[Double]):
Creates a vector initialized with the da array</B></P>
<P STYLE="font-weight: medium; text-decoration: none"><I>var da = new
Array[Double](20)</I></P>
<P STYLE="font-weight: medium; text-decoration: none"><I>da(3)=3</I></P>
<P STYLE="font-weight: medium; text-decoration: none"><I>var dav =
new Vec(da)</I></P>
<P><BR><BR>
</P>
<OL START=3>
	<LI><P><B>Construction by specifying the initial elements, e.g.</B></P>
	<P STYLE="font-weight: medium"><I>var v = V(&ldquo;4.5 5.6 -4&rdquo;)
	// space separated</I></P>
	<P STYLE="font-weight: medium"><I>var vv = V(&ldquo;4, -5.6, 6.7,
	-100.1&rdquo;) // comma separated </I>
	</P>
</OL>
<P STYLE="font-style: normal"><U><B>Basic Methods</B></U></P>
<P STYLE="font-style: normal; text-decoration: none"><A NAME="DDE_LINK2"></A>
<B>def size: Int // Returns the size of the Vector</B></P>
<P STYLE="font-style: normal; text-decoration: none"><B>def length:
Int // Returns the size of the Vector</B></P>
<P STYLE="font-weight: medium; text-decoration: none"><I>var l =
dav.size</I></P>
<P><BR><BR>
</P>
<P STYLE="text-decoration: none"><B>Vectors are dynamically resizable
while double[] arrays are not. An attempt to update a vector element
outside its current range increases automatically the vector's size
by a multiplicative factor, e.g. 1.5, in order to avoid frequent
resizing operations (which is somehow costly).</B></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P><B>Displaying the whole vector contents</B></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium">The whole contents of
the vector are printed to Console Standard Output with the <B>print</B>
<SPAN STYLE="font-weight: medium">routine, e.g.</SPAN></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var v = vrand(40) //
a random vector with 40 elements</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>v.print</I></P>
<P ALIGN=JUSTIFY><B>In-Place operators</B></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var v = vrand(100)</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo =
vones(v.length)</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>v++vo // adds to v
the vo vector</I></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY><I><B>Scalar append Vector operator ::</B></I></P>
<P ALIGN=JUSTIFY STYLE="font-style: normal; font-weight: medium">appends
a scalar to the end of a vector, e.g.</P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo = vones(4)</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo5 = 5 :: vo</I></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY><I><B>Scalar prepend Vector operator :::</B></I></P>
<P ALIGN=JUSTIFY STYLE="font-style: normal; font-weight: medium">prepends
a scalar to the start of a vector, e.g.</P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo = vones(4)</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo6 = 6 ::: vo</I></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY STYLE="margin-bottom: 0cm"><I><B>Vector append
Scalar operator ::&lt;</B></I></P>
<P ALIGN=JUSTIFY STYLE="font-style: normal; font-weight: medium">appends
a scalar to the end of a vector, e.g.</P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo = vones(4)</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo5 = vo ::&lt; 5</I></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY><I><B>Vector prepend Scalar operator :::&lt;</B></I></P>
<P ALIGN=JUSTIFY STYLE="font-style: normal; font-weight: medium">prepends
a scalar to the start of a vector, e.g.</P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo = vones(4)</I></P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>var vo6 = vo :::&lt;
6</I></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY><I><B>Vector append Vector operator :::</B></I></P>
<P ALIGN=JUSTIFY STYLE="font-style: normal; font-weight: medium">appends
the first vector at the start of the second, e.g.</P>
<P ALIGN=JUSTIFY STYLE="font-weight: medium"><I>vones(2) ::: vrand(5)</I></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY><B>Routines</B></P>
<P STYLE="font-weight: medium">1. <B>linspace: </B>Linearly spaced
vector.</P>
<P STYLE="font-weight: medium">linspace(x1, x2) generates a row
vector of 100 linearly <SPAN STYLE="font-weight: medium">equally
spaced points between x1 and x2.</SPAN></P>
<P STYLE="font-weight: medium">linspace(x1, x2, N) generates N points
between x1 and x2.</P>
<P STYLE="font-weight: medium"><I>var N = pow(2, 14) // signal length</I></P>
<P STYLE="font-weight: medium"><I>var t = linspace(0, 10, N) //
sample time axis</I></P>
<P STYLE="font-weight: medium"><I>var F1=30; var F2 = 4; // signal
frequencies</I></P>
<P STYLE="font-weight: medium"><I>var x = sin(F1*t)+2.4*cos(F2*t) //
construct synthetic signal</I></P>
<P STYLE="font-weight: medium"><I>var fftx = fft(x) // perform FFT</I></P>
<P STYLE="font-weight: medium"><I>figure(1); subplot(2,1,1); plot(x);
title(&ldquo;the signal&rdquo;);</I></P>
<P STYLE="font-weight: medium"><I>subplot(2,1,2); plot(fftx);
title(&ldquo;FFT of the signal&rdquo;)</I></P>
<P><BR><BR>
</P>
<P><BR><BR>
</P>
<P STYLE="font-weight: medium">2. <B>logspace: </B><SPAN STYLE="font-weight: medium">Logarithmically
spaced vector.</SPAN></P>
<P STYLE="font-weight: medium">logspace(x1, x2, N, base) generates a
row vector of N logarithmically <SPAN STYLE="font-weight: medium">equally
spaced points between x1 and x2. </SPAN>
</P>
<P STYLE="font-weight: medium">e.g.</P>
<P STYLE="font-weight: medium"><I>var x = logspace(1, 4, 100, 10)</I></P>
<P><BR><BR>
</P>
<P><B>3. dot :</B> <SPAN STYLE="font-weight: medium">Vector dot
product </SPAN>
</P>
<P STYLE="font-weight: medium">e.g.</P>
<P STYLE="font-weight: medium"><I>var t = inc(0, 0.001, 10)</I></P>
<P STYLE="font-weight: medium"><I>var x = t dot sin(3.2*t)</I></P>
<P STYLE="font-weight: medium"><I>plot(t,x)</I></P>
<P><BR><BR>
</P>
<P><I><B>4. vones(N: Int) : </B><SPAN STYLE="font-weight: medium">generates
a N-sized vector of ones</SPAN></I></P>
<P><I><B>5. vzeros(N: Int) : </B><SPAN STYLE="font-weight: medium">generates
a N-sized vector of zeros</SPAN></I></P>
<P><I><B>6. vfill(N: Int, value: Double): </B><SPAN STYLE="font-weight: medium">generates
a N-sized vector filled with value </SPAN></I>
</P>
<OL START=7>
	<LI><P><I><B>abs, min, max, sin, cos, tan, asin, acos, atan, sinh,
	cosh, tanh, ceil, floor, sqrt, log, exp: </B><SPAN STYLE="font-weight: medium">the
	corresponding routines</SPAN></I></P>
</OL>
<OL START=8>
	<LI><P><B>sum(v: Vec): </B><SPAN STYLE="font-weight: medium">sums
	the element of the vector</SPAN></P>
	<LI><P><B>mean(v: Vec): </B><SPAN STYLE="font-weight: medium">returns
	the mean value of the elements of the vector</SPAN></P>
</OL>
<P><BR><BR>
</P>
<P><B>Higher-order methods</B></P>
<P><BR><BR>
</P>
<P><B>a.  map</B></P>
<P STYLE="font-weight: medium">The <I>map </I><SPAN STYLE="font-style: normal">method
applies a function to all the elements of the vector, and returns a
new vector to keep the result, i.e. the original vector is unaltered,
e.g.</SPAN></P>
<P STYLE="font-weight: medium"><I>def  f(x: Double) = x*x*x  // x^3
function</I></P>
<P STYLE="font-weight: medium"><I>var  v = vfill(100, 2)  // a vector
filled with 2s</I></P>
<P STYLE="font-weight: medium"><I>var vc = v map f</I></P>
<P STYLE="font-weight: medium"> <I>var vadd2 = v map (_+2)   // adds
a 2 to all the elements of the vector</I></P>
<P STYLE="font-weight: medium"><BR><BR>
</P>
<P STYLE="font-weight: medium"><BR><BR>
</P>
<P STYLE="font-weight: medium"><BR><BR>
</P>
<P STYLE="font-weight: medium"><BR><BR>
</P>
</BODY>
</HTML>